import 'dart:convert';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:date_format/date_format.dart';
import 'package:flutter/material.dart' ;
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:mfkb/config/Config.dart';
import 'package:mfkb/pages/modules/Nothing.dart';
import 'package:mfkb/plugin/MyBehavior.dart';
import 'package:mfkb/service/DynamicService.dart';
import 'package:toast/toast.dart';

class RelationDetail extends StatefulWidget {
  int id ;
  RelationDetail({Key key , @required this.id}):super(key : key) ;
  @override
  _RelationDetailState createState() => _RelationDetailState();
}

class _RelationDetailState extends State<RelationDetail> {

  dynamic result = null ;
  dynamic reply = null ;
  var input = FocusNode();
  bool inputing = false ;
  var content = "" ;
  var place = "说几句为楼主打气～" ;
  var type = 0 ;
  dynamic indexs = [0 , 0] ;

  var did = 0 ;
  var mid = 0 ;

  @override
  void initState() {
    super.initState();
    DynamicService().getReplys(widget.id).then((value){
      if(value["code"] == 200){
        setState(() {
          reply = value["data"] ;
        });
      }else{
        Toast.show(value["msg"], context) ;
      }
    }) ;
    DynamicService().dynamicDetail(widget.id).then((value){
      if(value["code"] == 200){
        setState(() {
          result = value["data"] ;
        });
      }else{
        Toast.show(value["msg"], context) ;
      }
    }) ;
  }

  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.dark ,
      child: Scaffold(
        body: Stack(
          children: <Widget>[
            Column(
              children: <Widget>[
                Container(
                  height: MediaQuery.of(context).padding.top ,
                  color: Colors.white ,
                ) ,
                Container(
                  height: 45,
                  color: Colors.white ,
                  child: Row(
                    children: <Widget>[
                      Container(
                        width: 17,
                        height: 17,
                        margin: EdgeInsets.only(left:ScreenUtil().setWidth(19)),
                        child: GestureDetector(
                          child: Container(
                            width: 17,
                            height: 17,
                            child: Image.asset("assets/images/back.png" , fit: BoxFit.fill,),
                          ),
                          onTap: (){
                            Navigator.of(context).pop() ;
                          },
                        ),
                      ) ,
                      Expanded(
                        child: Container(
                          child: Center(
                            child: Text("动态详情" , style: TextStyle(
                              color: Color.fromARGB(255, 0, 0, 0) ,
                              fontSize: ScreenUtil().setSp(18) ,
                              fontWeight: FontWeight.bold 
                            ),),
                          ),
                        ),
                      ) ,
                      Container(
                        height: 17,
                        width: 36,
                      )
                    ],
                  ),
                ) ,
                Expanded(
                  child: ScrollConfiguration(
                    behavior: MyBehavior(),
                    child: ListView(
                      padding: EdgeInsets.all(0),
                      children: <Widget>[
                        Container(
                          width: ScreenUtil().setWidth(375),
                          color: Colors.white,
                          child: Container(
                            margin: EdgeInsets.only(left:ScreenUtil().setWidth(15) , right:ScreenUtil().setWidth(14)),
                            color: Colors.white ,
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start ,
                              children: <Widget>[
                                Container(
                                  height: ScreenUtil().setWidth(40),
                                  margin: EdgeInsets.only(top:ScreenUtil().setHeight(14)),
                                  child: Row(
                                    children: <Widget>[
                                      Container(
                                        width: ScreenUtil().setWidth(40),
                                        height: ScreenUtil().setWidth(40),
                                        child: ClipRRect(
                                          borderRadius: BorderRadius.all(Radius.circular(ScreenUtil().setWidth(40))),
                                          child: CachedNetworkImage(
                                            imageUrl: result == null ? "" : Config().getHost()+result["icon"],
                                            placeholder: (contex , url){
                                              return Container(
                                                color:Color.fromARGB(255, 246, 245, 248) ,
                                                child: Center(
                                                  child: Image.asset("assets/images/imageloading.png"),
                                                ) ,
                                              ) ;
                                            },
                                          ),
                                        )
                                      ) ,
                                      Expanded(
                                        child: Container(
                                          child: Column(
                                            crossAxisAlignment: CrossAxisAlignment.start,
                                            children: <Widget>[
                                              Container(
                                                height: ScreenUtil().setWidth(25),
                                                child: Row(
                                                  children: <Widget>[
                                                    Expanded(
                                                      child: Container(
                                                        margin: EdgeInsets.only(left:ScreenUtil().setWidth(10)),
                                                        child: Text(result == null ? "" : result["nickname"] , style: TextStyle(
                                                          fontSize: ScreenUtil().setSp(16) ,
                                                          color: Color.fromARGB(255, 19, 28, 53) ,
                                                          fontWeight: FontWeight.bold ,
                                                          fontFamily: "PingFang-SC-Bold,PingFang-SC"
                                                        ),),
                                                      ),
                                                    ) ,
                                                    // Container(
                                                    //   width: ScreenUtil().setWidth(80),
                                                    //   child: Text(
                                                    //     result == null ? "" : result["time"] , style: TextStyle(
                                                    //       fontSize: ScreenUtil().setSp(10) ,
                                                    //       color: Color.fromARGB(255, 121, 132, 155)
                                                    //     ),textAlign: TextAlign.end ,
                                                    //   ),
                                                    // )
                                                  ],
                                                ),
                                              ) ,
                                              Container(
                                                height: ScreenUtil().setWidth(15),
                                                margin: EdgeInsets.only(left:ScreenUtil().setWidth(10)),
                                                child: Text(result == null ? "" : result["school"] , textAlign: TextAlign.start,style: TextStyle(
                                                  fontSize: ScreenUtil().setSp(12) ,
                                                  height: ScreenUtil().setWidth(13) / ScreenUtil().setSp(12),
                                                  color:Color.fromARGB(255, 121, 132, 155)
                                                ),),
                                              )
                                            ],
                                          ),
                                        ),
                                      ) ,
                                    ],
                                  ),
                                ) ,
                                Container(
                                  margin: EdgeInsets.only(top:ScreenUtil().setHeight(14)),
                                  child: Text(result == null ? "" : result["content"] , style: TextStyle(
                                    fontSize: ScreenUtil().setSp(14) ,
                                    fontWeight: FontWeight.w500 
                                  ),),
                                ) ,
                                Visibility(
                                  visible: result != null && result["images"] != null && result["images"].length != 0,
                                  child: Container(
                                    margin: EdgeInsets.only(top:ScreenUtil().setHeight(result == null || result["images"] == null || result["images"].length == 0 ? 0 : 14)),
                                    child: Row(
                                      children: List.generate(result == null || result["images"] == null ? 0 : result["images"].length, (i){
                                        return  Container(
                                          width: ScreenUtil().setWidth(110),
                                          height: ScreenUtil().setWidth(110),
                                          margin: EdgeInsets.only(left:ScreenUtil().setWidth(i == 0 ? 0 : 8)),
                                          decoration: BoxDecoration(
                                            color: Colors.black ,
                                            borderRadius: BorderRadius.all(Radius.circular(8)),
                                          ) ,
                                          child: GestureDetector(
                                            child: ClipRRect(
                                              borderRadius: BorderRadius.all(Radius.circular(8)),
                                              child:CachedNetworkImage(
                                                imageUrl: result == null ? "" : Config().getHost()+result["images"][i]["url"],
                                                fit: BoxFit.cover ,
                                                placeholder: (contex , url){
                                                  return Container(
                                                    color:Color.fromARGB(255, 246, 245, 248) ,
                                                    child: Center(
                                                      child: Image.asset("assets/images/imageloading.png"),
                                                    ) ,
                                                  ) ;
                                                },
                                              )
                                            ) ,
                                            // onTap: (){  
                                            //   setState(() {
                                            //     swiper_list = _list[index]["images"] ;
                                            //     swiper_show = true ;
                                            //     swiper_index = i ;
                                            //   });
                                            // },
                                          )
                                        ) ;
                                      }),
                                    ),
                                  ),
                                ) ,
                                Container(
                                  height: ScreenUtil().setWidth(20),
                                  margin: EdgeInsets.only(bottom:ScreenUtil().setHeight(22) , top:ScreenUtil().setHeight(22)),
                                  child: Row(
                                    children: <Widget>[
                                      Container(
                                        margin: EdgeInsets.only(left:ScreenUtil().setWidth(144)),
                                        width: ScreenUtil().setWidth(80),
                                        child:GestureDetector(
                                          child: Row(
                                            children: <Widget>[
                                              Container(
                                                width: ScreenUtil().setWidth(20),
                                                height: ScreenUtil().setWidth(20),
                                                child: Image.asset("assets/images/talk.png"),
                                              ) ,
                                              Expanded(
                                                child: Container(
                                                  margin: EdgeInsets.only(left:ScreenUtil().setWidth(5)),
                                                  child: Text(result == null ? "" : result["talk"].toString() , style: TextStyle(
                                                    fontSize: ScreenUtil().setSp(14) ,
                                                    color: Color.fromARGB(255, 121, 132, 155)
                                                  ),),
                                                )
                                              )
                                            ],
                                          ),
                                        )
                                      ) ,
                                      Container(
                                        margin: EdgeInsets.only(left:ScreenUtil().setWidth(50)),
                                        width: ScreenUtil().setWidth(70),
                                        child:GestureDetector(
                                          child: Row(
                                            children: <Widget>[
                                              Container(
                                                width: ScreenUtil().setWidth(20),
                                                height: ScreenUtil().setWidth(20),
                                                child: result == null || result["gid"] == null ? Image.asset("assets/images/up.png") : Image.asset("assets/images/up_active.png"),
                                              ) ,
                                              Expanded(
                                                child: Container(
                                                  margin: EdgeInsets.only(left:ScreenUtil().setWidth(5)),
                                                  child: Text(result == null ? "0" : result["up"].toString() , style: TextStyle(
                                                    fontSize: ScreenUtil().setSp(14) ,
                                                    color: Color.fromARGB(255, 121, 132, 155)
                                                  ),),
                                                )
                                              )
                                            ],
                                          ),
                                          onTap: () {
                                            if(result == null) return ;
                                            if(result["gid"] == null){
                                              DynamicService().up(result["id"] , 1).then((value){
                                                if(value["code"] == 200){
                                                  setState(() {
                                                    result["gid"] = 1 ;
                                                    result["up"]++ ;
                                                  });
                                                }  
                                              }) ;
                                            }else{
                                              DynamicService().up(result["id"] , 0).then((value){
                                                if(value["code"] == 200){
                                                  setState(() {
                                                    result["gid"] = null ;
                                                    result["up"]-- ;
                                                  });
                                                }  
                                              }) ;
                                            }
                                          },
                                        )
                                      )
                                    ],
                                  ),
                                ) ,
                              ],
                            ),
                          ),
                        ) ,
                        Container(
                          margin: EdgeInsets.only(top:ScreenUtil().setHeight(9)),
                          color: Colors.white ,
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start ,
                            children: <Widget>[
                              Container(
                                height: ScreenUtil().setHeight(24),
                                margin: EdgeInsets.only(left:ScreenUtil().setWidth(15) , right:ScreenUtil().setWidth(15) , top:ScreenUtil().setHeight(10) , bottom: ScreenUtil().setHeight(10)),
                                child: Text("评论"+(result == null ? "0" : result["talk"].toString()) , style: TextStyle(
                                  fontSize: ScreenUtil().setSp(16) ,
                                  height: ScreenUtil().setHeight(24) / ScreenUtil().setSp(16) ,
                                  fontWeight: FontWeight.bold ,
                                  color: Color.fromARGB(255, 51, 51, 51)
                                ),),
                              ) ,
                              Container(
                                height: 36,
                                margin: EdgeInsets.only(left:ScreenUtil().setWidth(15) , right:ScreenUtil().setWidth(15) , top:ScreenUtil().setHeight(16) , bottom:ScreenUtil().setHeight(10)),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.start ,
                                  children: <Widget>[
                                    ClipRRect(
                                      borderRadius: BorderRadius.all(Radius.circular(18)),
                                      child: Container(
                                        width: 36,
                                        height: 36,
                                        child: CachedNetworkImage(
                                          imageUrl: Config().getHost()+jsonDecode(Config().getUserInfo())["icon"] ,
                                          placeholder: (context , url){
                                            return Container(
                                              color:Color.fromARGB(255, 246, 245, 248) ,
                                              child: Center(
                                                child: Image.asset("assets/images/imageloading.png"),
                                              ) ,
                                            ) ;
                                          },
                                        ),
                                      ),
                                    ) ,
                                    Expanded(
                                      child: Container(
                                        margin: EdgeInsets.only(left:ScreenUtil().setWidth(10)),
                                        height: 36 ,
                                        decoration: BoxDecoration(
                                          borderRadius: BorderRadius.all(Radius.circular(18)) ,
                                          color: Color.fromARGB(255, 236, 237, 241) ,
                                          border: Border.all(
                                            color:Color.fromARGB(255, 236, 237, 241)
                                          )
                                        ),
                                        child: GestureDetector (
                                          child:Container(
                                            height: 20,
                                            margin: EdgeInsets.only(left:ScreenUtil().setWidth(18) , top:7.5),
                                            child: Text("说几句为楼主打气～" , style: TextStyle(
                                              fontSize: ScreenUtil().setSp(14) ,
                                              height: 20 / ScreenUtil().setSp(14) ,
                                              color: Color.fromARGB(255, 121, 132, 155) ,
                                            ),),
                                          ) ,
                                          onTap: (){
                                            did = widget.id ;
                                            mid = 0 ;
                                            type = 0 ;
                                            setState(() {
                                              inputing = true ;
                                              Future.delayed(Duration(milliseconds: 200) , (){
                                                FocusScope.of(context).requestFocus(input) ;
                                              }) ;
                                            });
                                          },
                                        )
                                      ),
                                    )
                                  ],
                                ),
                              ) ,
                            ],
                          ),
                        ) ,
                        reply == null || reply.length == 0 ? Container(
                          child: Nothing(),
                        ) : Column(
                          children: List.generate(reply.length, (index){
                            // print(reply) ;
                            return Container(
                              width: ScreenUtil().setWidth(375),
                              color: Colors.white ,
                              child: Container(
                                margin: EdgeInsets.only(left:ScreenUtil().setWidth(15) , right:ScreenUtil().setWidth(15) , top:ScreenUtil().setHeight(18)),
                                child: Row(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    Container(
                                      width: 36 ,
                                      height: 36 ,
                                      margin: EdgeInsets.only(top:0),
                                      child: ClipRRect(
                                        borderRadius: BorderRadius.all(Radius.circular(18)),
                                        child: CachedNetworkImage(
                                          imageUrl: Config().getHost()+reply[index]["userReply"]["icon"],
                                          placeholder: (context , url){
                                            return Container(
                                              color:Color.fromARGB(255, 246, 245, 248) ,
                                              child: Center(
                                                child: Image.asset("assets/images/imageloading.png"),
                                              ) ,
                                            ) ;
                                          },
                                        ),
                                      ),
                                    ) ,
                                    Expanded(
                                      child: Container(
                                        margin: EdgeInsets.only(left:ScreenUtil().setWidth(11)),
                                        child: Column(
                                          crossAxisAlignment: CrossAxisAlignment.start ,
                                          children: <Widget>[
                                            Row(
                                              children: <Widget>[
                                                Expanded(
                                                  child: Container(
                                                    height: 34 ,
                                                    child: Column(
                                                      crossAxisAlignment: CrossAxisAlignment.start ,
                                                      children: <Widget>[
                                                        Container(
                                                          height: 20 ,
                                                          child: Text(reply[index]["userReply"]["nickname"] , style: TextStyle(
                                                            fontSize: 14 ,
                                                            fontWeight: FontWeight.bold ,
                                                            color:Color.fromARGB(255, 19, 28, 53) ,
                                                            height: 18 / 14
                                                          ),overflow: TextOverflow.ellipsis,),
                                                        ) ,
                                                        Container(
                                                          height: 14 ,
                                                          child: Text(reply[index]["time"] , style: TextStyle(
                                                            fontSize: 10 ,
                                                            color:Color.fromARGB(255, 121, 132, 155) ,
                                                            height: 10 / 10
                                                          ),overflow: TextOverflow.ellipsis,),
                                                        )
                                                      ],
                                                    ),
                                                  ),
                                                ) ,
                                                GestureDetector(
                                                  child: Container(
                                                    width: 50 ,
                                                    height: 20 ,
                                                    margin: EdgeInsets.only(top:5 , bottom:11),
                                                    child: Row(
                                                      children: <Widget>[
                                                        Container(
                                                          width: 20 ,
                                                          height: 20 ,
                                                          child: Image.asset("assets/images/talk.png" , fit: BoxFit.fill,),
                                                        ) ,
                                                        Container(
                                                          width: 26 ,
                                                          margin: EdgeInsets.only(left:4),
                                                          child: Text("回复" , style: TextStyle(
                                                            fontSize: 12 ,
                                                            color: Color.fromARGB(255, 121, 132, 155)
                                                          ),) ,
                                                        )
                                                      ],
                                                    ),
                                                  ),
                                                  onTap: (){
                                                    did = widget.id ;
                                                    mid = reply[index]["rid"] ;
                                                    type = 1 ;
                                                    indexs[0] = index ;
                                                    place = "回复 "+reply[index]["userReply"]["nickname"]+"：" ;
                                                    setState(() {
                                                      inputing = true ;
                                                      Future.delayed(Duration(milliseconds: 200) , (){
                                                        FocusScope.of(context).requestFocus(input) ;
                                                      }) ;
                                                    });
                                                  },
                                                )
                                              ],
                                            ) ,
                                            Container(
                                              margin: EdgeInsets.only(top:ScreenUtil().setHeight(8)),
                                              color:Colors.white ,
                                              child: Text(reply[index]["content"] , style: TextStyle(
                                                fontSize: 14 ,
                                                color: Color.fromARGB(255, 46, 52, 73) ,
                                                height: 20 / 14
                                              ),),
                                            ) ,
                                            Container(
                                              width: ScreenUtil().setWidth(375),
                                              margin: EdgeInsets.only(top:ScreenUtil().setHeight(9) , bottom:ScreenUtil().setHeight(10)),
                                              decoration: BoxDecoration(
                                                color: Color.fromARGB(255, 246, 246, 248) ,
                                                borderRadius: BorderRadius.all(Radius.circular(5))
                                              ),
                                              child: Column(
                                                crossAxisAlignment: CrossAxisAlignment.start ,
                                                children: List.generate(reply[index]["replys"] == null || reply[index]["replys"].length == 0 ? 0 : reply[index]["replys"].length, (i){
                                                  return GestureDetector(
                                                    child: Container(
                                                      margin: EdgeInsets.only(top:ScreenUtil().setHeight(i == 0 ? 11 : 8) , left:ScreenUtil().setWidth(12) , right:ScreenUtil().setWidth(12) , bottom:ScreenUtil().setHeight(i+1 == reply[index]["replys"].length ? 8 : 0)),
                                                      child: Text.rich(
                                                        TextSpan(
                                                          children: [
                                                            TextSpan(text:reply[index]["replys"][i]["userReply"]["nickname"] , style: TextStyle(
                                                              fontSize: 12 ,
                                                              color: reply[index]["replys"][i]["publisher"] == reply[index]["publisher"] ? Color.fromARGB(255, 78, 86, 108) : Color.fromARGB(255, 0, 167, 178) ,
                                                              fontWeight: FontWeight.bold 
                                                            ),) ,
                                                            TextSpan(text:"回复" , style: TextStyle(
                                                              fontSize: 12 ,
                                                              fontWeight: FontWeight.bold ,
                                                              color: Color.fromARGB(255 , 46, 52, 73)
                                                            ),) ,
                                                            TextSpan(text:reply[index]["replys"][i]["userReplyTo"]["nickname"]+"：" , style: TextStyle(
                                                              fontSize: 12 ,
                                                              color: reply[index]["replys"][i]["publisher"] == reply[index]["publisher"] ? Color.fromARGB(255, 78, 86, 108) : Color.fromARGB(255, 0, 167, 178) ,
                                                              fontWeight: FontWeight.bold 
                                                            ),) ,
                                                            TextSpan(text:reply[index]["replys"][i]["content"] , style: TextStyle(
                                                              fontSize: 12 ,
                                                              color: Color.fromARGB(255, 46, 52, 73)
                                                            ),)
                                                          ]
                                                        )
                                                      ) ,
                                                    ),
                                                    onTap: (){
                                                      did = widget.id ;
                                                      mid = reply[index]["replys"][i]["rid"] ;
                                                      type = 2 ;
                                                      indexs[0] = index ;
                                                      indexs[1] = i ;
                                                      place = "回复"+reply[index]["replys"][i]["userReply"]["nickname"]+"：" ;
                                                      setState(() {
                                                        inputing = true ;
                                                        Future.delayed(Duration(milliseconds: 200) , (){
                                                          FocusScope.of(context).requestFocus(input) ;
                                                        }) ;
                                                      });
                                                    },
                                                  ) ;
                                                }) ,
                                              ),
                                            )
                                          ],
                                        ),
                                      ),
                                    ) ,
                                  ],
                                ),
                              ),
                            ) ;
                          }) ,
                        )
                      ],
                    ),
                  ),
                )
              ],
            ) ,
            Positioned(
              bottom: 0 ,
              left:0 ,
              child: Visibility(
                visible: inputing ,
                child: GestureDetector(
                  child: Container(
                    height: ScreenUtil().setHeight(812) ,
                    width: ScreenUtil().setWidth(375)  ,
                    color: Color.fromARGB(160, 0, 0, 0) ,
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.end ,
                      children: <Widget>[
                        Container(
                          height: 50 ,
                          width: ScreenUtil().setWidth(375),
                          color: Colors.white ,
                          child: GestureDetector(
                            child: Container(
                              margin: EdgeInsets.only(left:ScreenUtil().setWidth(8) , right:ScreenUtil().setWidth(8)),
                              child: Row(
                                children: <Widget>[
                                  Expanded(
                                    child:Container(
                                      height: 40 ,
                                      margin: EdgeInsets.only(right:5),
                                      decoration: BoxDecoration(
                                        border: Border.all(
                                          color:Color.fromARGB(255, 0, 195, 206) ,
                                          width: 2 
                                        )
                                      ),
                                      child: TextField(
                                        focusNode: input ,
                                        decoration: InputDecoration(
                                          hintText: place ,
                                          border: InputBorder.none ,
                                          hintStyle: TextStyle(
                                            fontSize: 14 ,
                                            height: 20 / 14
                                          )
                                        ),
                                        style: TextStyle(
                                          fontSize: 14 ,
                                          height: 20 / 14
                                        ),
                                        onChanged: (value){
                                          content = value ;
                                        },
                                      ),
                                    )
                                  ) ,
                                  GestureDetector(
                                    child: Container(
                                      width: 80,
                                      height: 40,
                                      decoration: BoxDecoration(
                                        color: Color.fromARGB(255, 0, 195, 206) , 
                                        borderRadius: BorderRadius.all(Radius.circular(10))
                                      ),
                                      child: Center(
                                        child: Text("发送" , style: TextStyle(
                                          fontSize: 14 ,
                                          color: Colors.white ,
                                          fontWeight: FontWeight.bold 
                                        ),),
                                      ),
                                    ),
                                    onTap: (){
                                      DynamicService().reply(widget.id , did, mid, content).then((value){
                                        if(value["code"] == 200){
                                          if(type == 0){
                                            reply.add({"rid":value["data"]["id"] , "content":"$content" , "time":formatDate(DateTime.now(), [yyyy, "/", mm, "/", dd]) ,
                                            "publisher":value["data"]["uid"] , "userReply":{"nickname":jsonDecode(Config().getUserInfo())["nickname"] , "icon":
                                            jsonDecode(Config().getUserInfo())["icon"]} , "replys":[]}) ;
                                          }else if(type == 1){
                                            reply[indexs[0]]["replys"].add({"rid":value["data"]["id"] , "content":"$content" , "time":formatDate(DateTime.now(), [yyyy, "/", mm, "/", dd]) ,
                                            "publisher":value["data"]["uid"] , "userReply":{"nickname":jsonDecode(Config().getUserInfo())["nickname"] , "icon":
                                            jsonDecode(Config().getUserInfo())["icon"]} , "userReplyTo":{"nickname":reply[indexs[0]]["userReply"]["nickname"] , "icon":
                                            reply[indexs[0]]["userReply"]["icon"]}}) ;
                                          }else{
                                            reply[indexs[0]]["replys"].add({"rid":value["data"]["id"] , "content":"$content" , "time":formatDate(DateTime.now(), [yyyy, "/", mm, "/", dd]) ,
                                            "publisher":value["data"]["uid"] , "userReply":{"nickname":jsonDecode(Config().getUserInfo())["nickname"] , "icon":
                                            jsonDecode(Config().getUserInfo())["icon"]} , "userReplyTo":{"nickname":reply[indexs[0]]["replys"][indexs[1]]["userReply"]["nickname"] , "icon":
                                            reply[indexs[0]]["replys"][indexs[1]]["userReply"]["icon"]}}) ;
                                          }
                                          setState(() {
                                            inputing = false ;
                                          });
                                        }else{
                                          Toast.show(value["msg"], context) ;
                                        }
                                      }) ;
                                    },
                                  )
                                ],
                              ),
                            ),
                            onTap: (){

                            },
                          ),
                        )
                      ],
                    ),
                  ),
                  onTap: (){
                    setState(() {
                      inputing = false ;
                    });
                  },
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}